package easy.springioc.beans.config;

public class BeanDefinition {

    private String beanId;
    private Object beanInstance;

    public BeanDefinition(String beanId, Object beanInstance) {
        this.beanId = beanId;
        this.beanInstance = beanInstance;
    }


    public String getBeanName() {
        return toLowerFirstWord(beanInstance.getClass().getSimpleName());
    }

    public String getBeanId() {
        return beanId;
    }

    public Object getBeanInstance() {
        return beanInstance;
    }

    /**
     * 把字符串的首字母小写
     * @param name
     * @return
     */
    private String toLowerFirstWord(String name){
        char[] charArray = name.toCharArray();
        charArray[0] += 32;
        return String.valueOf(charArray);
    }
}
